package com.society.sgsc.utils;

public class CommonResult<T> {
    private int code;
    private String message;
    private T data;

    // 必须有无参构造方法
    public CommonResult() {
    }

    // 必须有 getter 方法
    public int getCode() { return code; }
    public String getMessage() { return message; }
    public T getData() { return data; }

    // 静态工厂方法
    public static <T> CommonResult<T> success(T data) {
        CommonResult<T> result = new CommonResult<>();
        result.code = 200;
        result.message = "成功";
        result.data = data;
        return result;
    }

    public static <T> CommonResult<T> error(int code, String message) {
        CommonResult<T> result = new CommonResult<>();
        result.code = code;
        result.message = message;
        return result;
    }
}